<?php
// 本类由系统自动生成，仅供测试用途
class PostAction extends Action {

public function pre_1_update() {

		$Data = $_REQUEST["Data"];

		if (session('idinfo_finance')) {
			$Dao = D("infofinance");

			$vo['idinfo_finance'] = session('idinfo_finance');
			$vo['project_pid'] = session('pid');
			$vo['type'] = $Data['type'];
			$vo['scale'] = $Data['scale'];
			$vo['thisyear'] = $Data['thisyear'];
			$vo['assessment'] = $Data['assessment'];
			$vo['isleader'] = $Data['isleader'];
			$vo['other'] = $Data['other'];
			$vo['post'] = $Data['post'];
			
			
			if (false !== $Dao -> save($vo)) 
			{
				$message="【".session('nickname')."】更新了【".session('pname')."】的 项目融资信息表";
				$this->sendmessage($message);
				print_r("update!");
			}
			 else
				print_r("error!");

		} else {

			$Dao = D("infofinance");

			$vo['project_pid'] = session('pid');
			$vo['type'] = $Data['type'];
			$vo['scale'] = $Data['scale'];
			$vo['thisyear'] = $Data['thisyear'];
			$vo['assessment'] = $Data['assessment'];
			$vo['isleader'] = $Data['isleader'];
			$vo['other'] = $Data['other'];
			$vo['post'] = $Data['post'];
			
			if ($sid=$Dao -> add($vo)) {
				session('idinfo_finance',$sid);
				$message="【".session('nickname')."】创建【".session('pname')."】的 项目融资信息表";
				$this->sendmessage($message);
				print_r("add!");
			} else
				print_r("error!");
		}

	}
	public function pre_1() {
		if (session('pid')) {
			$Dao = D("infofinance");
			$condition['project_pid'] = session('pid');
			$list = $Dao -> where($condition) -> find();
			
			if ($list)
				session('idinfo_finance', $list['idinfo_finance']);

			$Data = json_encode($list);
			print_r($Data);
		} else {
			$list["error"] = "error";
			$Data = json_encode($list);
			print_r($Data);
		}
	}
	public function post_2_update() {

		$Data = $_REQUEST["Data"];

		if (session('idsafeguardclause')) {
			$Dao = D("safeguardclause");

			$vo['idsafeguardclause'] = session('idsafeguardclause');
			$vo['project_pid'] = session('pid');
			$vo['type'] = $Data['type'];
			$vo['condition'] = $Data['condition'];
			$vo['content'] = $Data['content'];
			$vo['detailcontent'] = $Data['detailcontent'];

			if (false !== $Dao -> save($vo)) 
			{
				$message="【".session('nickname')."】更新了【".session('pname')."】的 项目投资保护条款";
				$this->sendmessage($message);
				$Data = json_encode($vo);
				print_r($Data);
			}
			 else
				print_r("error!");

		} else {

			$Dao = D("safeguardclause");

			$vo['project_pid'] = session('pid');

			$vo['type'] = $Data['type'];
			$vo['condition'] = $Data['condition'];
			$vo['content'] = $Data['content'];
			$vo['detailcontent'] = $Data['detailcontent'];
			if ($sid=$Dao -> add($vo)) {
				session('idsafeguardclause',$sid);
				$message="【".session('nickname')."】创建【".session('pname')."】的 项目投资保护条款";
				$this->sendmessage($message);
				print_r("add!");
			} else
				print_r("error!");
		}

	}
	public function post_1() {
		$key = $_REQUEST["key1"];
		

		$pageIndex = $_REQUEST["pageIndex"];
		$pageSize = $_REQUEST["pageSize"];

		$sortField = $_REQUEST["sortField"];
		$sortOrder = $_REQUEST["sortOrder"];

		if (!empty($sortField)) {
			if ($sortOrder != "desc")
				$sortOrder = "asc";
			$order = $sortField . " " . $sortOrder;
		} else {
			$order = "icid desc";
		}

		
		
		$condition['project_pid'] = session('pid');

		$Dao = D("Investchange");

		$total = $Dao -> where($condition) -> count();

		//dump($total);
		$list = $Dao -> where($condition) -> order($order) -> limit($pageIndex * $pageSize . ',' . $pageSize) -> select();

		//dump($list);
		$resultData = array("total" => $total, "data" => $list);

		$Data = json_encode($resultData);
		print_r($Data);

	}
	public function post_1_5() {
		$reason = $_REQUEST["key1"];
		

		$pageIndex = $_REQUEST["pageIndex"];
		$pageSize = $_REQUEST["pageSize"];

		$sortField = $_REQUEST["sortField"];
		$sortOrder = $_REQUEST["sortOrder"];

		if (!empty($sortField)) {
			if ($sortOrder != "desc")
				$sortOrder = "asc";
			$order = $sortField . " " . $sortOrder;
		} else {
			$order = "vcid desc";
		}

		$condition['reason'] = array('like', '%' . $reason . '%');
		
		$condition['project_pid'] = session('pid');

		$Dao = D("valuechange");

		$total = $Dao -> where($condition) -> count();

		//dump($total);
		$list = $Dao -> where($condition) -> order($order) -> limit($pageIndex * $pageSize . ',' . $pageSize) -> select();

		//dump($list);
		$resultData = array("total" => $total, "data" => $list);

		$Data = json_encode($resultData);
		print_r($Data);

	}
		public function showfile() {
		
		$key=$_REQUEST["key"];
		$pageIndex = $_REQUEST["pageIndex"];
		$pageSize = $_REQUEST["pageSize"];

		$sortField = $_REQUEST["sortField"];
		$sortOrder = $_REQUEST["sortOrder"];

		if (!empty($sortField)) {
			if ($sortOrder != "desc")
				$sortOrder = "asc";
			$order = $sortField . " " . $sortOrder;
		} else {
			$order = "fid desc";
		}

		$condition['orginalname'] = array('like', '%' . $key . '%');
		$condition['project'] = session('pname');
		$Dao = D("file");

		$total = $Dao -> where($condition) -> count();

		//dump($total);
		$list = $Dao -> where($condition) -> order($order) -> limit($pageIndex * $pageSize . ',' . $pageSize) -> select();

		//dump($list);
		$resultData = array("total" => $total, "data" => $list);

		$Data = json_encode($resultData);
		print_r($Data);

	}
public function showfile1() {
		

		$pageIndex = $_REQUEST["pageIndex"];
		$pageSize = $_REQUEST["pageSize"];

		$sortField = $_REQUEST["sortField"];
		$sortOrder = $_REQUEST["sortOrder"];

		if (!empty($sortField)) {
			if ($sortOrder != "desc")
				$sortOrder = "asc";
			$order = $sortField . " " . $sortOrder;
		} else {
			$order = "fid desc";
		}

		
		$condition['project'] = session('pname');
		$condition['level'] = session('level');
		$Dao = D("file");

		$total = $Dao -> where($condition) -> count();

		//dump($total);
		$list = $Dao -> where($condition) -> order($order) -> limit($pageIndex * $pageSize . ',' . $pageSize) -> select();

		//dump($list);
		$resultData = array("total" => $total, "data" => $list);

		$Data = json_encode($resultData);
		print_r($Data);

	}
	public function post_2() {
		if (session('pid')) {
			$Dao = D("safeguardclause");
			$condition['project_pid'] = session('pid');
			$list = $Dao -> where($condition) -> find();
			
			if ($list)
				session('idsafeguardclause', $list['idsafeguardclause']);
			
			$this->assign ( 'list', $list );
			$Data = json_encode($list);
			print_r($Data);
		} else {
			$list["error"] = "error";
			$Data = json_encode($list);
			print_r($Data);
		}
	}

	public function post_4() {

		$pageIndex = $_REQUEST["pageIndex"];
		$pageSize = $_REQUEST["pageSize"];

		$sortField = $_REQUEST["sortField"];
		$sortOrder = $_REQUEST["sortOrder"];

		if (!empty($sortField)) {
			if ($sortOrder != "desc")
				$sortOrder = "asc";
			$order = $sortField . " " . $sortOrder;
		} else {
			$order = "idcompany_finance desc";
		}

		$condition['project_pid'] = session('pid');

		$Dao = D("Company_finance");

		$total = $Dao -> where($condition) -> count();

		//dump($total);
		$list = $Dao -> where($condition) -> order($order) -> limit($pageIndex * $pageSize . ',' . $pageSize) -> select();

		//dump($list);
		$resultData = array("total" => $total, "data" => $list);

		$Data = json_encode($resultData);
		print_r($Data);

	}

	public function post_5() {
		$info = $_REQUEST["key1"];
		$determine = $_REQUEST["key2"];

		$pageIndex = $_REQUEST["pageIndex"];
		$pageSize = $_REQUEST["pageSize"];

		$sortField = $_REQUEST["sortField"];
		$sortOrder = $_REQUEST["sortOrder"];

		if (!empty($sortField)) {
			if ($sortOrder != "desc")
				$sortOrder = "asc";
			$order = $sortField . " " . $sortOrder;
		} else {
			$order = "idinfo_tracking desc";
		}

		$condition['info'] = array('like', '%' . $info . '%');
		$condition['determine'] = array('like', '%' . $determine . '%');
		$condition['project_pid'] = session('pid');

		$Dao = D("Info_tracking");

		$total = $Dao -> where($condition) -> count();

		//dump($total);
		$list = $Dao -> where($condition) -> order($order) -> limit($pageIndex * $pageSize . ',' . $pageSize) -> select();

		//dump($list);
		$resultData = array("total" => $total, "data" => $list);

		$Data = json_encode($resultData);
		print_r($Data);

	}

	public function post_6() {
		$content = $_REQUEST["key1"];
		$pageIndex = $_REQUEST["pageIndex"];
		$pageSize = $_REQUEST["pageSize"];

		$sortField = $_REQUEST["sortField"];
		$sortOrder = $_REQUEST["sortOrder"];

		if (!empty($sortField)) {
			if ($sortOrder != "desc")
				$sortOrder = "asc";
			$order = $sortField . " " . $sortOrder;
		} else {
			$order = "idadditionservice desc";
		}

		$condition['content'] = array('like', '%' . $content . '%');
		$condition['project_pid'] = session('pid');

		$Dao = D("Additionservice");

		$total = $Dao -> where($condition) -> count();

		//dump($total);
		$list = $Dao -> where($condition) -> order($order) -> limit($pageIndex * $pageSize . ',' . $pageSize) -> select();

		//dump($list);
		$resultData = array("total" => $total, "data" => $list);

		$Data = json_encode($resultData);
		print_r($Data);

	}
	public function quit_1() {
		
		$pageIndex = $_REQUEST["pageIndex"];
		$pageSize = $_REQUEST["pageSize"];

		$sortField = $_REQUEST["sortField"];
		$sortOrder = $_REQUEST["sortOrder"];

		if (!empty($sortField)) {
			if ($sortOrder != "desc")
				$sortOrder = "asc";
			$order = $sortField . " " . $sortOrder;
		} else {
			$order = "idquitinfo desc";
		}

		
		$condition['project_pid'] = session('pid');

		$Dao = D("Quitinfo");

		$total = $Dao -> where($condition) -> count();

		//dump($total);
		$list = $Dao -> where($condition) -> order($order) -> limit($pageIndex * $pageSize . ',' . $pageSize) -> select();

		//dump($list);
		$resultData = array("total" => $total, "data" => $list);

		$Data = json_encode($resultData);
		print_r($Data);

	}
	

	public function post_5_add() {

		$Data = $_REQUEST["Data"];
		$Dao = D("Info_tracking");

		$Data["project_pid"] = session('pid');

		if ($Dao -> add($Data))
			{
				$message="【".session('nickname')."】增加了【".session('pname')."】的 项目重要信息跟踪表";
				$this->sendmessage($message);
				print_r("success!");
			}
		else
			print_r("error!");

	}
	public function post_5_update() {

		$Data = $_REQUEST["Data"];
		$Dao = D("Info_tracking");
		

		if ($Dao -> save($Data))
			{
				$message="【".session('nickname')."】更新了【".session('pname')."】的 项目重要信息跟踪表";
				$this->sendmessage($message);
				print_r("success!");
			}
		else
			print_r("error!");

		}
	public function post_6_add() {

		$Data = $_REQUEST["Data"];
		$Dao = D("Additionservice");

		$Data["project_pid"] = session('pid');

		if ($Dao -> add($Data))
			{
				$message="【".session('nickname')."】增加了【".session('pname')."】的项目增值服务表";
				$this->sendmessage($message);
				print_r("success!");
			}
		else
			print_r("error!");

	}
	public function post_6_update() {

		$Data = $_REQUEST["Data"];
		$Dao = D("Additionservice");

		

		if ($Dao -> save($Data))
			{
				$message="【".session('nickname')."】更新了【".session('pname')."】的项目增值服务表";
				$this->sendmessage($message);
				print_r("success!");
			}
		else
			print_r("error!");

	}
	public function post_4_add() {

		$Data = $_REQUEST["Data"];
		$Dao = D("company_finance");

		$Data["project_pid"] = session('pid');

		if ($Dao -> add($Data))
			{
				$message="【".session('nickname')."】增加了【".session('pname')."】的项目公司财务数据摘要";
				$this->sendmessage($message);
				print_r("success!");
			}
		else
			print_r("error!");

	}
	public function post_4_update() {

		$Data = $_REQUEST["Data"];
		$Dao = D("company_finance");

		
		if ($Dao -> save($Data))
			{
				$message="【".session('nickname')."】更新了【".session('pname')."】的项目公司财务数据摘要";
				$this->sendmessage($message);
				print_r("success!");
			}
		else
			print_r("error!");

	}
	public function post_1_5_add() {

		$Data = $_REQUEST["Data"];
		$Dao = D("Valuechange");

		$Data["project_pid"] = session('pid');

		if ($Dao -> add($Data))
			{
				$message="【".session('nickname')."】增加了【".session('pname')."】的项目估值变动表";
				$this->sendmessage($message);
				print_r("success!");
			}
		else
			print_r("error!");

	}
	public function quit_1_add() {

		$Data = $_REQUEST["Data"];
		$Dao = D("Quitinfo");

		$Data["project_pid"] = session('pid');

		if ($Dao -> add($Data))
			{
				$message="【".session('nickname')."】增加了【".session('pname')."的项目退出信息条";
				$this->sendmessage($message);
				print_r("success!");
			}
		else
			print_r("error!");

	}
	public function quit_1_update() {

		$Data = $_REQUEST["Data"];
		$Dao = D("Quitinfo");

		if ($Dao -> save($Data))
			{
				$message="【".session('nickname')."】更新了【".session('pname')."的项目退出信息条";
				$this->sendmessage($message);
				print_r("success!");
			}
		else
			print_r("error!");

	}
	public function post_1_add() {

		$Data = $_REQUEST["Data"];
		$Dao = D("Investchange");

		$Data["project_pid"] = session('pid');

		if ($Dao -> add($Data))
			{
				$message="【".session('nickname')."】增加了【".session('pname')."】项目投资及股权变动信息";
				$this->sendmessage($message);
				print_r("success!");
			}
		else
			print_r("error!");

	}
	public function post_1_update() {

		$Data = $_REQUEST["Data"];
		$Dao = D("Investchange");

		if ($Dao -> save($Data))
			{
				$message="【".session('nickname')."】更新了【".session('pname')."】项目投资及股权变动信息";
				$this->sendmessage($message);
				print_r("success!");
			}
		else
			print_r("error!");

	}

	public function sendmessage($message){
		$Dao=D("Mail");
		$Data['sendname']="系统";
		$Data['getname']=session('managername');
		$Data['senddate']=date('Y-m-d');
		$Data['content']=$message;
		$Data['title']="系统消息";
		
		$Dao->add($Data);		
			
	}
}
